home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / JFC.bin / MotifTreeCellRenderer.java < prev    next >
Text File  |  1998-06-30  |  3KB  |  110 lines

  1. /*
  2.  * @(#)MotifTreeCellRenderer.java    1.5 98/02/02
  3.  * 
  4.  * Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  */
  20.  
  21. package com.sun.java.swing.plaf.motif;
  22.  
  23. import com.sun.java.swing.*;
  24. import com.sun.java.swing.plaf.*;
  25. import com.sun.java.swing.tree.*;
  26. import com.sun.java.swing.plaf.basic.BasicTreeCellRenderer;
  27. import java.awt.*;
  28. import java.awt.event.*;
  29. import java.beans.*;
  30. import java.io.*;
  31. import java.util.*;
  32.  
  33. /**
  34.  * Motif rendered to display a tree cell.
  35.  * <p>
  36.  * Warning: serialized objects of this class will not be compatible with
  37.  * future swing releases.  The current serialization support is appropriate
  38.  * for short term storage or RMI between Swing1.0 applications.  It will
  39.  * not be possible to load serialized Swing1.0 objects with future releases
  40.  * of Swing.  The JDK1.2 release of Swing will be the compatibility
  41.  * baseline for the serialized form of Swing objects.
  42.  *
  43.  * @version 1.5 02/02/98
  44.  * @author Jeff Dinkins
  45.  */
  46. public class MotifTreeCellRenderer extends BasicTreeCellRenderer
  47. {
  48.     static final int LEAF_SIZE = 13;
  49.     static final Icon LEAF_ICON = new IconUIResource(new TreeLeafIcon());
  50.  
  51.     public MotifTreeCellRenderer() {
  52.     super();
  53.     }
  54.  
  55.     public static Icon loadLeafIcon() {
  56.     return LEAF_ICON;
  57.     }
  58.  
  59.     /**
  60.      * Icon for a node with no children.
  61.      * <p>
  62.      * Warning: serialized objects of this class will not be compatible with
  63.      * future swing releases.  The current serialization support is appropriate
  64.      * for short term storage or RMI between Swing1.0 applications.  It will
  65.      * not be possible to load serialized Swing1.0 objects with future releases
  66.      * of Swing.  The JDK1.2 release of Swing will be the compatibility
  67.      * baseline for the serialized form of Swing objects.
  68.      */
  69.     public static class TreeLeafIcon implements Icon, Serializable {
  70.  
  71.     Color bg;
  72.     Color shadow;
  73.     Color highlight;
  74.  
  75.     public TreeLeafIcon() {
  76.         bg = UIManager.getColor("Tree.iconBackground");
  77.         shadow = UIManager.getColor("Tree.iconShadow");
  78.         highlight = UIManager.getColor("Tree.iconHighlight");
  79.     }
  80.  
  81.     public void paintIcon(Component c, Graphics g, int x, int y) {
  82.         g.setColor(bg);
  83.         g.fillRect(4, 7, 5, 5);
  84.  
  85.         g.drawLine(6, 6, 6, 6);
  86.         g.drawLine(3, 9, 3, 9);
  87.         g.drawLine(6, 12, 6, 12);
  88.         g.drawLine(9, 9, 9, 9);
  89.  
  90.         g.setColor(highlight);
  91.         g.drawLine(2, 9, 5, 6);
  92.         g.drawLine(3, 10, 5, 12);
  93.  
  94.         g.setColor(shadow);
  95.         g.drawLine(6, 13, 10, 9);
  96.         g.drawLine(9, 8, 7, 6);
  97.         
  98.     }
  99.     
  100.     public int getIconWidth() {
  101.         return LEAF_SIZE;
  102.     }
  103.     
  104.     public int getIconHeight() {
  105.         return LEAF_SIZE;
  106.     }
  107.     
  108.     }
  109. }
  110.